home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 2.iso / Utils / UNIX / UNZIP520 / WINGUI / ABOUT.C next >
C/C++ Source or Header  |  1996-03-03  |  3KB  |  109 lines

  1. #include <windows.h>    /* required for all Windows applications */
  2. #include <stdio.h>
  3.  
  4. #include "wingui\wizunzip.h"
  5. #include "version.h"
  6.  
  7. /*
  8.  -      CenterDialog
  9.  -      
  10.  *      Purpose:
  11.  *              Moves the dialog specified by hwndDlg so that it is centered on
  12.  *              the window specified by hwndParent. If hwndParent is null,
  13.  *              hwndDlg gets centered on the screen.
  14.  *      
  15.  *              Should be called while processing the WM_INITDIALOG message
  16.  *              from the dialog's DlgProc().
  17.  *      
  18.  *      Arguments:
  19.  *              HWND    parent hwnd
  20.  *              HWND    dialog's hwnd
  21.  *      
  22.  *      Returns:
  23.  *              Nothing.
  24.  *
  25.  */
  26. void
  27. CenterDialog(HWND hwndParent, HWND hwndDlg)
  28. {
  29.         RECT    rectDlg;
  30.         RECT    rect;
  31.         int             dx;
  32.         int             dy;
  33.  
  34.         if (hwndParent == NULL)
  35.         {
  36.                 rect.top = rect.left = 0;
  37.                 rect.right = GetSystemMetrics(SM_CXSCREEN);
  38.                 rect.bottom = GetSystemMetrics(SM_CYSCREEN);
  39.         }
  40.         else
  41.         {
  42.                 GetWindowRect(hwndParent, &rect);
  43.         }
  44.  
  45.         GetWindowRect(hwndDlg, &rectDlg);
  46.         OffsetRect(&rectDlg, -rectDlg.left, -rectDlg.top);
  47.  
  48.         dx = (rect.left + (rect.right - rect.left -
  49.                         rectDlg.right) / 2 + 4) & ~7;
  50.         dy = rect.top + (rect.bottom - rect.top -
  51.                         rectDlg.bottom) / 2;
  52.         WinAssert(hwndDlg);
  53.         MoveWindow(hwndDlg, dx, dy, rectDlg.right, rectDlg.bottom, 0);
  54. }
  55.  
  56.  
  57. /****************************************************************************
  58.  
  59.     FUNCTION: About(HWND, unsigned, WPARAM, LPARAM)
  60.  
  61.     PURPOSE:  Processes messages for "About" dialog box
  62.  
  63.     MESSAGES:
  64.  
  65.     WM_INITDIALOG - initialize dialog box
  66.     WM_COMMAND    - Input received
  67.  
  68. ****************************************************************************/
  69.  
  70. #ifdef __BORLANDC__
  71. #pragma argsused
  72. #endif
  73. BOOL WINAPI
  74. AboutProc(HWND hwndDlg, WORD wMessage, WPARAM wParam, LPARAM lParam)
  75. {
  76. char string[80];
  77.  
  78. if ((wMessage == WM_CLOSE) ||
  79.     (wMessage == WM_COMMAND && LOWORD(wParam) == IDOK))
  80.         EndDialog(hwndDlg, TRUE);
  81.  
  82. if (wMessage == WM_INITDIALOG)
  83.    {
  84. #ifndef USEWIZUNZDLL
  85. #  ifndef WIN32
  86.      SetWindowText(hwndDlg, "About WizUnZip (16-Bit) Version");
  87. #  else
  88.      SetWindowText(hwndDlg, "About WizUnZip (32-Bit) Version");
  89. #  endif
  90. #else
  91. #  ifndef WIN32
  92.      SetWindowText(hwndDlg, "About WizUnZip (16-Bit) DLL Version");
  93. #  else
  94.      SetWindowText(hwndDlg, "About WizUnZip (32-Bit) DLL Version");
  95. #  endif
  96. #endif
  97.    sprintf(string, "Version %d.%d%s %s", WIZUZ_MAJORVER, WIZUZ_MINORVER,
  98.       BETALEVEL, WIN_VERSION_DATE);
  99.    SetDlgItemText(hwndDlg, IDM_ABOUT_VERSION_INFO, string);
  100.    sprintf(string, "Based on Info-ZIP's UnZip version %d.%d%s",
  101.       UZ_MAJORVER, UZ_MINORVER, BETALEVEL);
  102.    SetDlgItemText(hwndDlg, IDM_ABOUT_UNZIP_INFO, string);
  103.    CenterDialog(GetParent(hwndDlg), hwndDlg);
  104.    }
  105. return ((wMessage == WM_CLOSE) || (wMessage == WM_INITDIALOG) || (wMessage == WM_COMMAND))
  106.             ? TRUE : FALSE;
  107. }
  108.  
  109.